﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Index
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2>Index</h2>
    <input id="buttonTest" value="Test" type="button"></input>

    </input>


    <div class="mydiv">test</div>
    <div class="mydiv">test</div>

    <br />
    <br />
    <br />
    <br />
    <textarea id="TextArea1" cols="20" name="S1"></textarea><input id="buttonPost" value="Post" type="button"> 

</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="HeadContent" runat="server">
    <script src="../../Scripts/jquery-1.4.4.js" type="text/javascript"></script>

    <script type="text/javascript">
        $(function () {
            $.fn.myPlugin = function () {
                return this.each(function () {
                    $(this).html("you used myPlugin!");
                });
            };
            $("#buttonTest").click(function () {
                $(".mydiv").myPlugin();
            });

            $("#buttonPost").click(function () {
                PostMsg();
            });
        });

        function PostMsg() {
            $.post("/jQ/GetMsg", { Msg: $("#TextArea1").val() }, function (response) { ProcessResponse(response) });
        }

        function ProcessResponse(response) {
            var text = "";
            for (var i = 0; i < response.length; i++) {
                text = text + response[i].ID + " " + response[i].Name + " " + response[i].Old
                text = text + "\n"
            }        
            $("#TextArea1").val(text);
        }
    </script>
    <style type="text/css">
        #TextArea1
        {
            height: 80px;
        }
    </style>
</asp:Content>
